<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:p="http://primefaces.org/ui" xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:composition template="home2.xhtml" >
        <ui:define name="css" >
            <h:outputStylesheet library="css" name="amigo.css" />
        </ui:define>
        <ui:define name="title" >
            <h:outputText value="Perfil de #{usuarioMB.us.nome}" /> 
        </ui:define>
        <ui:define name="content" >
            <p:panel styleClass="painel centro" id="centro" >
                <h:form prependId="false">
                <p:dataTable id="tabela" value="#{conviteMB.convites}" var="convite" paginatorPosition="top" 
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
                             emptyMessage="Nenhum convite pendente" paginatorAlwaysVisible="false" >
                    <f:facet name="header" >Solicitações de amizades pendentes</f:facet>
                    <p:column>
                        <p:graphicImage value="#{convite.userSender.fotoPerfil}" width="35" height="35"/>
                        <p:commandLink value="#{convite.userSender.nome} #{convite.userSender.sobrenome}" action="#{usuarioMB.perfilAmigo}">
                            <f:setPropertyActionListener target="#{usuarioMB.amigo}" value="#{convite.userSender}" />
                        </p:commandLink>
                        <br /><h:outputLabel value="#{convite.texto}" />
                    </p:column>
                    <p:column>
                        <f:facet name="header" >Ação</f:facet>
                        <p:commandButton icon="ui-icon-circle-check" value="accept" action="#{conviteMB.aceitar}" ajax="false" >
                            <f:setPropertyActionListener target="#{conviteMB.c}" value="#{convite}" />
                        </p:commandButton>
                        <p:commandButton icon="ui-icon-circle-close" value="reject" action="#{conviteMB.recusar}" ajax="false">
                            <f:setPropertyActionListener target="#{conviteMB.c}" value="#{convite}" />
                        </p:commandButton>
                    </p:column>
                </p:dataTable>
                </h:form>
            </p:panel>
        </ui:define>
    </ui:composition>
</html>